<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>input上传样式</title>
    <style>
        .file {
            position: relative;
            height: 40px;
            line-height: 40px;
        }

        .file label {
            display: inline-block;
        }

        .userdefined-file {
            position: absolute;
            top: 0;
            left: 60px;
            z-index: 2;
            width: 300px;
            height: 40px;
            line-height: 40px;
            font-size: 0;
            /*应对子元素为 inline-block 引起的外边距*/
        }

        .userdefined-file input[type="text"] {
            display: inline-block;
            vertical-align: middle;
            padding-right: 14px;
            padding-left: 14px;
            width: 220px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            position: fixed;
        }

        .userdefined-file button {
            display: inline-block;
            vertical-align: middle;
            width: 80px;
            text-align: center;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            background-color: #f54;
            border: none;
            color: #fff;
            cursor: pointer;
        }

        .file input[type="file"] {
            position: absolute;
            top: 0;
            left: 60px;
            z-index: 3;
            opacity: 0;
            width: 300px;
            height: 40px;
            line-height: 40px;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <form action="" class="activityForm">
        <div class="file">
            <label for="file"></label>
            <div class="userdefined-file">
                <input type="text" name="userdefinedFile" id="userdefinedFile" value="未选择任何文件">
                <button type="button">上传</button>
            </div>
            <input type="file" name="file" id="file">
        </div>
    </form>
    <input type="text" id="checkNum">
    <input type="radio" name="sex" value="男" id="">
    <input type="radio" name="sex" value="女" id="">
    <button type="button" id="selman">选择男</button>
    <button type="button" id="selwoman">选择女</button>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
        $("#selman").on("click",function(){
            $("input[value=男]").prop("checked",true);//
        })
        $("#selwoman").on("click",function(){
            $("input[value=女]").prop("checked",true);//
        })
        document.getElementById("file").onchange = function () {
            document.getElementById("userdefinedFile").value = document.getElementById("file").value;
            upMyTips("是否上传？")
        }

        function upMyTips(text, func) {
            var all = $("<div style='width:100%;height:100%;z-index:999;position:fixed;top:0px;left:0px;'>" +
                "<div style='position:absolute;top:0px;left:0px;width:100%;height:100%;filter:alpha(opacity=20);opacity:0.2;background:black;'></div>" +
                "<div style='position:absolute;top:0px;left:0px;width:100%;height:100%;'>" +
                "<table style='border-radius:10px;max-width:300px;margin:auto;margin-top:150px;background:#fff;text-align:center;'>" +
                "<tr><td style='padding:20px 35px;border-bottom:1px solid #eee;' colspan='2' >" + text +
                "</td></tr>" +
                "<tr style='line-height:40px;color:#097EFF;'><td cancel width='80' style='border-right:1px solid #eee;'>取消</td><td confirm width='80'>确认</td></tr>" +
                "</table></div></div>");
            $("body").append(all);
            all.find("td[cancel]").click(function () {
                all.remove()
            });
            all.find("td[confirm]").click(function () {
                func();
                all.remove();
            });
        }

        function toFixed(num, s) {
            var times = Math.pow(10, s)
            var des = num * times + 0.5
            des = parseInt(des, 10) / times
            return des + ''
        }
        console.log(toFixed(99.123456, 4));
        //监听键盘，只允许输入数字和小数点
        $("#checkNum").keypress(function (event) {
            var keyCode = event.which;
            if (keyCode == 46 || (keyCode >= 48 && keyCode <= 57))
                return true;
            else
                return false;
        }).focus(function () {
            this.style.imeMode = 'disabled';
        });

    </script>
</body>

</html>